/**
 * 
 */
package com.star.encryption;

import java.io.IOException;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;

import javax.crypto.KeyGenerator;
import javax.crypto.SecretKey;

/**
 * @ClassName: GenerateKey
 * @Description: TODO
 * @author starhq
 * @createtime 2014年11月29日 下午3:03:15
 * @email : jian.wang@shinsoft.net
 * @modify by TODO
 * @resaon
 * @edittime
 * @version 1.0
 * @copyright shinsoft
 */
public class GenerateKey {

	public static void main(String[] args) throws NoSuchAlgorithmException,
			IOException {
		String keyFileName = "key.data";
		String algorithm = "DES";

		SecureRandom sr = new SecureRandom();
		KeyGenerator kg = KeyGenerator.getInstance(algorithm);
		kg.init(sr);
		SecretKey key = kg.generateKey();

		KeyUtil.writeKey(keyFileName, key.getEncoded());
	}
}
